<script type='text/javascript' src='<?php echo $this->webroot; ?>js/plugins/validationEngine/languages/jquery.validationEngine-es.js'></script>
<script type='text/javascript' src='<?php echo $this->webroot; ?>js/plugins/validationEngine/jquery.validationEngine.js'></script>    

<?php
App::uses('CakeNumber', 'Utility');
App::import('model', 'Movimiento');
$movimientoo = new Movimiento();
$movimiento = $movimientoo->find('first', array('order' => 'Movimiento.id DESC'));

App::import('Model', 'Pedido');
$Pedido = new Pedido();
$numero = $Pedido->find('count', array(
    'conditions' => array('Pedido.estado' => '0')
        ));

App::import('User', 'Model');
$modeloUsers = new User();
$dcd = $modeloUsers->find('all', array(
    'recursive' => -1,
    'conditions' => array('User.role' => 'diler')
        ));

App::import('Porcentaje', 'Model');
$modeloPorcentaje = new Porcentaje();
$dcp = $modeloPorcentaje->find('all', array(
    'recursive' => -1,
    'fields' => array('id', 'monto')
        ));

App::import('Movimiento', 'Model');
$modeloMovimiento = new Movimiento();
$mov = $modeloMovimiento->find('all', array(
    'recursive' => 0,
    'limit' => 10,
    'order' => 'Movimiento.id DESC'
        ));
//debug($mov);
?>

<ul class="navigation">    

    <li>
        <a href="#" class="button yellow">
            <div class="arrow"></div>
            <div class="icon">
                <span class="ico-money-bag"></span>
            </div>                    
            <?php //$formatoMoneda = money_format('Bs', $movimiento['Movimiento']['total']); ?>
            <div class="name"><?php echo CakeNumber::currency($movimiento['Movimiento']['total'], ' '); ?></div>
        </a>  
    </li>

    <li>
        <script>
            setInterval('consulta()', 3000);
            //setTimeout ("consulta()", 5000);
            function consulta()
            {
                //consulta con un ajax si hay nuevas notificaciones
                //alert("eynar");
                $('#pendientes').load('<?php echo $this->Html->url(array('controller' => 'Pedidos', 'action' => 'ajaxpendientes', $numero)) ?>');
            }
        </script>

        <?php
//        echo $this->Ajax->remoteTimer(
//                array(
//                    'url' => array('controller' => 'Pedidos', 'action' => 'ajaxpendientes', $numero),
//                    'update' => 'pendientes', 'position' => 'append', 'frequency' => 30
//                )
//        );
        ?>
        <a href="<?php echo $this->Html->url(array('controller' => 'Pedidos', 'action' => 'listado')); ?>" class="button red">
            <div align="center" >               
                <div class="arrow"></div>
                <div class="icon">
                    <span class="ico-alarm-clock"></span>
                </div>                    
                <div class="name" id="pendientes">Pend. <?php echo $numero ?></div>                
            </div>            
        </a>
    </li>

    <li>
        <a href="#bModal" role="button" data-toggle="modal" class="button bl_blue" onclick="$('#contenidomodal').load('<?php echo $this->Html->url(array('controller' => 'Pedidos','action'=> 'recargamodal'));?>');">
            <div class="arrow"></div>
            <div class="icon">
                <span class="ico-arrow-up"></span>
            </div>                    
            <div class="name">Recargar</div>
        </a>  
    </li>

    <li>
        <a href="#bModal" role="button" data-toggle="modal" class="button green" onclick="$('#contenidomodal').load('<?php echo $this->Html->url(array('controller' => 'Movimientos','action'=> 'modalreversion'));?>');">
            <div class="arrow"></div>
            <div class="icon">
                <span class="ico-retweet"></span>
            </div>                    
            <div class="name">Reversion</div>
        </a>  
    </li>       

    <li>
        <a href="#bModal" role="button" data-toggle="modal" class="button purple" onclick="$('#contenidomodal').load('<?php echo $this->Html->url(array('controller' => 'Pedidos','action'=> 'ingresomodal'));?>');">
            <div class="arrow"></div>
            <div class="icon">
                <span class="ico-plus"></span>
            </div>                    
            <div class="name">Rec. Almacen </div>
        </a>
    </li>

    <!--    <li>
            <a href="<?php //echo $this->Html->url(array('controller' => 'Users', 'action' => 'salir'));          ?>" class="button red">
                <div class="arrow"></div>
                <div class="icon">
                    <span class="ico-off"></span>
                </div>                    
                <div class="name">Salir </div>
            </a>
        </li>-->

    <li>
        <div class="user">
            <img src="<?php echo $this->webroot; ?>img/examples/users/dmitry_m.jpg" align="left" />
            <a href="#" class="name">
                <span><?php echo $this->Session->read('Auth.User.nombre'); ?></span>
                <span class="sm">
                    Mega dealer
                </span>
            </a>
        </div>

        <div class="buttons">            
            <div class="sbutton green navButton">
                <a href="#"><span class="ico-align-justify"></span></a>
            </div>

            <div class="sbutton red">
                <a href="<?php echo $this->Html->url(array('controller' => 'Users', 'action' => 'salir')); ?>"><span class="ico-off"></span></a>                
            </div>
        </div>
    </li> 
</ul>                

<div id="fcAddEvent" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="fcAddEventLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">?</button>
        <h3 id="fcAddEventLabel">Add new event</h3>
    </div>
    <div class="modal-body">
        <div class="row-fluid">
            <div class="span3">Title:</div>
            <div class="span9"><input type="text" id="fcAddEventTitle"/></div>
        </div>
    </div>
    <div class="modal-footer">            
        <button class="btn btn-primary" id="fcAddEventButton">Add</button>            
    </div>
</div> 

<!--<div id="bModales" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">-->